<!--  -->
<template>
  <div class="set-more-site">
    <el-form :model="form" v-loading="loading" ref="siteMoreSet">
      <el-form-item label="禁止网页复制：" :label-width="formLabelWidth">
        <el-radio-group v-model="form.disabledCopy" @change="changeDdisabledCopy">
          <el-radio size="mini" :label="1">开启</el-radio>
          <el-radio size="mini" :label="0">关闭</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="设置网站灰度：" :label-width="formLabelWidth">
        <el-radio-group v-model="form.siteGray" @change="changeSiteGray">
          <el-radio size="mini" :label="1">开启</el-radio>
          <el-radio size="mini" :label="0">关闭</el-radio>
        </el-radio-group>
        <span class="note">（用于纪念重大灾难日）</span>
      </el-form-item>
      <el-form-item label="底部备案展示：" :label-width="formLabelWidth">
        <el-radio-group v-model="form.webRecord" @change="changeWebRecord">
          <el-radio size="mini" :label="1">开启</el-radio>
          <el-radio size="mini" :label="0">关闭</el-radio>
        </el-radio-group>
        <span class="note">（启用后网站底部将展示备案信息）</span>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  created () {
    this.getData()
  },
  data () {
    return {
      loading: false,
      formLabelWidth: '120px',
      form: {
        siteGray: 0,
        disabledCopy: 0,
        webRecord: 0
      }
    }
  },
  methods: {
    getData () {
      this.loading = true
      this.$post('/host/web-site-config', null).then(response => {
        if (response) {
          this.form.siteGray = response.siteGray
          this.form.disabledCopy = response.disabledCopy
          this.form.webRecord = response.webRecord
        } else {
        }
        this.loading = false
      })
    },
    changeSiteGray (value) {
      this.loading = true
      this.$post('/host/update-web-site-config-site-gray', { siteGray: value }).then(response => {
        if (response) {
          this.form.siteGray = response.siteGray
          this.form.disabledCopy = response.disabledCopy
          this.form.webRecord = response.webRecord
        } else {
        }
        this.loading = false
      })
    },
    changeDdisabledCopy (value) {
      this.loading = true
      this.$post('/host/update-web-site-config-disabled-copy', { disabledCopy: value }).then(response => {
        if (response) {
          this.form.siteGray = response.siteGray
          this.form.disabledCopy = response.disabledCopy
          this.form.webRecord = response.webRecord
        } else {
        }
        this.loading = false
      })
    },
    changeWebRecord (value) {
      this.loading = true
      this.$post('/host/update-web-site-config-web-record', { webRecord: value }).then(response => {
        if (response) {
          this.form.siteGray = response.siteGray
          this.form.disabledCopy = response.disabledCopy
          this.form.webRecord = response.webRecord
        } else {
        }
        this.loading = false
      })
    }
  },
  components: {
  }
}
</script>
<style scoped>
.set-more-site {
  margin-top: 12px;
  margin-left: 24px;
}
.set-more-site .el-form-item{
  margin-bottom: 5px;
}
.note {
  font-size: 13px;
  color: #666;
  margin-left: 15px;
}
</style>
